<template>
    <div id="todayAddIntentAccountIndex_" class="padding">
        <!--查询的字段与条件-->
        <div id="details">
            <el-form :model="params" :inline="true" ref="params" label-width="100px" class="padding">
                <el-form-item label="来电号码" prop="ldhm">
                    <el-input v-model="params.ldhm" style="width: 300px;"></el-input>
                </el-form-item>
                <el-form-item label="客户名称" prop="khmc">
                    <el-input v-model="params.khmc" style="width: 300px;"></el-input>
                </el-form-item>
                <el-form-item label="客户需求" prop="khxq">
                    <el-select v-model="params.khxq" style="width: 300px;">
                        <el-option value="" label=""></el-option>
                        <el-option v-for="item in datas['客户需求']['children']" v-bind:key="item.id" v-bind:value="item.text" >{{item.text}}</el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="质询产品" prop="zxcp">
                    <el-input v-model="params.zxcp" style="width: 300px;"></el-input>
                </el-form-item>
                <el-form-item label=" ">
                    <el-button type="primary" @click="cx()">查询</el-button>
                    <el-button @click="$refs['params'].resetFields()">重置</el-button>
                </el-form-item>
            </el-form>
        </div>
        <el-table
                :data="tableData"
                border
                style="width: 100%">
            <el-table-column
                    prop="khmc"
                    label="客户名称">
            </el-table-column>
            <el-table-column
                    prop="ldhm"
                    label="来电号码">
            </el-table-column>
            <el-table-column
                    prop="khxq"
                    label="客户需求">
            </el-table-column>
            <el-table-column
                    prop="zxcp"
                    label="质询产品">
            </el-table-column>
            <el-table-column
                    prop="gxsj"
                    label="最近联系时间"
                    :formatter="formatter">
            </el-table-column>
            <el-table-column
                    prop="dhfsj"
                    label="待回访时间"
                    :formatter="formatter">
            </el-table-column>
            <el-table-column
                    prop="ygmc"
                    label="归属员工">
            </el-table-column>
        </el-table>
        <div class="padding" style="float: right">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="page"
                    :page-sizes="pageSizes"
                    :page-size="limit"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="count">
            </el-pagination>
        </div>
    </div>
</template>

<script>
    import {formatDateTime} from '../../../../common/js/util';
    export default {
        name: "todayAddIntentAccountIndex",
        beforeCreate: function () {
            this.$nextTick(function () {
                //查找字典数据，然后填充到数据框里面
                this.$post('basic-information-system-dict/special-list',{CrmSystemDictSearch: {code_type_name: Object.keys(this.datas)}},this)
                    .then((response) => {//这里使用了ES6的语法
                        if (response.data.res == 1) {//成功
                            this.datas = response.data.data;
                        }else{//失败
                            layer.msg("查询失败！"+response.data.data[0],{icon:2})
                        }
                    }).catch((response) => {
                    consoleLog(response)
                });
                this.page = 1;
                this.limit = this.pageSizes[0];
                this.searchList(this.limit,this.page);
            });
        },
        data() {
            return {
                tableData: [],
                page: 0,
                count: 0,
                limit: 0,
                pageSizes: [30, 90, 120, 300],
                params:{
                    ldhm:"",//来电号码
                    zxcp:"",
                    khmc:"",
                    khxq:"",
                },
                datas: {//字典查找
                    '客户需求': {children: {}},
                },
            }
        },
        methods: {
            formatter(row, column, cellValue, index){
                return formatDateTime(cellValue);
            },
            searchList(limit,page){
                this.$post('basic-information-system-tj/today-add-intent-account-list',{limit:limit,page:page})
                    .then((response) => {
                        if (response.data.code == 1) {
                            this.tableData=response.data.data;
                            this.page = response.data.page;
                            this.count = parseInt(response.data.count);
                        }else{//失败
                        }
                    }).catch((response) => {
                    consoleLog(response)
                });
            },
            handleSizeChange(val) {
                this.searchList(val,this.page);
            },
            handleCurrentChange(val) {
                this.searchList(this.limit,val);
            },
            handleClick(val) {
                this.clickRow = val;//点击的那一行
                if (val.config_souye==null||val.config_souye==''){//为空，表示所有的都显示
                    this.clickRow.config_souye = this.$configSouye;
                }
                layer.open({
                    type: 1,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['70%','70%'], //宽高
                    close: true,
                    title: '配置首页模块',
                    shadeClose: true,
                    content: $('#config'),
                    end: () => {//关闭隐藏
                    }
                });
            },
            save:function () {
                this.clickRow.config_souye = JSON.stringify(this.clickRow.config_souye)
                this.$post('basic-information-system-tj/save',{CrmSystemYgxx_:this.clickRow})
                    .then((response) => {
                        if (response.data.res == 1) {
                            this.$message({'message':'保存成功','type':'success'});
                        }else{//失败
                            this.$message({'message':'保存成功','type':'error'});
                        }
                    }).catch((response) => {
                    consoleLog(response)
                });
                this.clickRow.config_souye = JSON.parse(this.clickRow.config_souye)
            },
            cx:function () {//查询
                this.$post('basic-information-system-tj/today-add-intent-account-list',{limit:this.limit,page:this.page,CrmHwzxSearch:this.params})
                    .then((response) => {
                        if (response.data.code == 1) {
                            this.tableData=response.data.data;
                            this.page = response.data.page;
                            this.count = parseInt(response.data.count);
                        }else{//失败
                        }
                    }).catch((response) => {
                    consoleLog(response)
                });
            },
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>